<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>好朋友数挑战 - 设置</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .container {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            text-align: center;
            max-width: 400px;
            width: 100%;
        }

        h1 {
            color: #4a5568;
            font-size: 2.2em;
            margin-bottom: 30px;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
        }

        .setting-group {
            margin-bottom: 30px;
        }

        .setting-label {
            font-size: 1.3em;
            color: #4a5568;
            margin-bottom: 15px;
            font-weight: bold;
        }

        .number-input {
            font-size: 2em;
            padding: 15px;
            border: 3px solid #4ecdc4;
            border-radius: 15px;
            text-align: center;
            width: 120px;
            margin: 0 auto;
            display: block;
            background: #f7fafc;
            color: #2d3748;
            font-weight: bold;
        }

        .number-input:focus {
            outline: none;
            border-color: #38a169;
            box-shadow: 0 0 0 3px rgba(56, 161, 105, 0.1);
        }

        .buttons {
            display: flex;
            gap: 20px;
            justify-content: center;
            margin-top: 30px;
        }

        .btn {
            padding: 15px 30px;
            font-size: 1.3em;
            font-weight: bold;
            border: none;
            border-radius: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
            color: white;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
        }

        .btn-start {
            background: linear-gradient(45deg, #48bb78, #38a169);
        }

        .btn-back {
            background: linear-gradient(45deg, #a0aec0, #718096);
        }

        .btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
        }

        .description {
            color: #718096;
            font-size: 1.1em;
            margin-bottom: 25px;
            line-height: 1.5;
        }

        .range-info {
            color: #4a5568;
            font-size: 0.9em;
            margin-top: 10px;
        }

        @media (max-width: 480px) {
            .container {
                padding: 30px 20px;
                margin: 10px;
            }
            
            h1 {
                font-size: 1.8em;
            }
            
            .buttons {
                flex-direction: column;
                gap: 15px;
            }
            
            .btn {
                padding: 12px 25px;
                font-size: 1.2em;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>👫 好朋友数挑战</h1>
        
        <div class="description">
            欢迎来到好朋友数挑战！<br>
            请设置你想要挑战的题目数量。
        </div>
        
        <div class="setting-group">
            <div class="setting-label">题目数量</div>
            <input type="number" id="questionCount" class="number-input" value="10" min="1" max="20">
            <div class="range-info">可设置 1-20 题</div>
        </div>
        
        <div class="buttons">
            <button class="btn btn-back" onclick="goBack()">返回</button>
            <button class="btn btn-start" onclick="startGame()">开始挑战</button>
        </div>
    </div>

    <script>
        // 返回主页
        function goBack() {
            window.location.href = 'index.html';
        }

        // 开始游戏
        function startGame() {
            const questionCount = document.getElementById('questionCount').value;
            const count = parseInt(questionCount);
            
            // 验证输入
            if (isNaN(count) || count < 1 || count > 20) {
                alert('请输入1-20之间的数字！');
                return;
            }
            
            // 将题目数量保存到localStorage，然后跳转到游戏页面
            localStorage.setItem('friendNumbersQuestionCount', count);
            window.location.href = 'friend-numbers.html';
        }

        // 输入框验证
        document.getElementById('questionCount').addEventListener('input', function() {
            const value = parseInt(this.value);
            if (value < 1) {
                this.value = 1;
            } else if (value > 20) {
                this.value = 20;
            }
        });

        // 回车键开始游戏
        document.getElementById('questionCount').addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                startGame();
            }
        });
    </script>
</body>
</html>